package com.hk.manage.login.enums;

import com.hk.commons.eunms.Enums;

import java.text.MessageFormat;

/**
 * 登录错误枚举
 * 900开头
 */
public enum UserErrorEnum implements Enums<String> {


    LOGIN_ERROR_ENUM("900901", "用户名或密码有误！"),
    LOGIN_ENABLE_ENUM("900902", "该用户已被禁用！"),
    LOGIN_LOCK_ENUM("900903", "该用户登录错误过多已被锁定！请稍后登录！"),
    REGISTER_REPEAT("900904", "用户已存在！"),
    ;
    private String code;
    private String desc;

    UserErrorEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    @Override
    public String getCode() {
        return this.code;
    }

    @Override
    public String getDesc() {
        return this.desc;
    }

    @Override
    public String getDesc(Object... objs) {
        return MessageFormat.format(this.desc, objs);
    }

    //通过value获取对应的枚举对象
    public static UserErrorEnum getEnums(String value) {
        for (UserErrorEnum code : UserErrorEnum.values()) {
            if (code.getCode().equals(value)) {
                return code;
            }
        }
        return null;
    }

}
